package wh.FishingPhilosopher;

import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;

public class OptionsScreenActivity extends Activity {
	CheckBox optionMusicCheckBox;
	CheckBox optionSoundCheckBox;
	Button optionSaveButton;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setFullScreen();
        setContentView(R.layout.options_screen);
        optionMusicCheckBox = (CheckBox)findViewById(R.id.OptionMusic);
        optionSoundCheckBox = (CheckBox)findViewById(R.id.OptionSound);
        optionSaveButton=(Button)findViewById(R.id.OptionSave);
	}
	
	public void optionSaveButtonOnClick(View view){
		saveGameOptions();
	}

	public void onStart(){
		loadGameOptions();
		super.onStart();
	}
	
	private void saveGameOptions(){
	    Editor editor = getSharedPreferences("gameOptions", 0).edit();
	    editor.putBoolean("musicOption", optionMusicCheckBox.isChecked());
	    editor.putBoolean("soundOption", optionSoundCheckBox.isChecked());
	    editor.commit();
	    finish();
	}
	private void loadGameOptions(){
		SharedPreferences gameOptions = getSharedPreferences("gameOptions", 0);
		optionMusicCheckBox.setChecked(gameOptions.getBoolean("musicOption", true));
		optionSoundCheckBox.setChecked(gameOptions.getBoolean("soundOption", true));
	}
	private void setFullScreen() {
    	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
	}

}
